<?php
    $today = date("Y-m-d");
    // create a new XML document
    $doc = new DomDocument('1.0', 'utf-8'); // ISO-8859-1

    // create root node
    $root = $doc->createElement('root');
    $root = $doc->appendChild($root);

        $occ = $doc->createElement('custtable');
        $occ = $root->appendChild($occ);

            $child = $doc->createElement('accountnum');
            $child = $occ->appendChild($child);
            $value = $doc->createTextNode("$accountnum");
            $value = $child->appendChild($value);

            $child = $doc->createElement('name');
            $child = $occ->appendChild($child);
            $value = $doc->createTextNode("$name");
            $value = $child->appendChild($value);

            $child = $doc->createElement('date');
            $child = $occ->appendChild($child);
            $value = $doc->createTextNode("$today");
            $value = $child->appendChild($value);


    // get completed xml document
    $xml_string = $doc->saveXML();

    $xml_string = utf8_encode($xml_string);

    $myFile = "logs/$accountnum.xml";
    $fh = fopen($myFile, 'w') or die("can't open file");
    fwrite($fh, $xml_string);
    fclose($fh);
?>
